<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of m_giay
 *
 * @author Tuyet
 */
class M_sanpham extends CI_Model {

  function __construct() {
    parent::__construct();
    $this->load->database();
  }

  public function insertProduct($data) {
    if ($this->db->insert('products', $data)) {
      return true;
    } else {
      return false;
    }
  }

  function getallproducts() {
    $query = $this->db->get('products');
    $result = $query->result();
    return $result;    
  }

  function getProduct($productid) {
    $results = $this->db->get_where('products', array('product_id' => "$productid"))->row_array();
    //$result = $results[0];
    return $results;
  }

  function getProductbyID($product_id) {
    $this->db->select('*');
    $this->db->from('products');
    $this->db->where('product_id', 1111);
    $query = $this->db->get();
    $result = $query->result();
    return $result;
  }

}

?>
